package com.yp.lession71.slice;

import com.yp.lession71.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        //设置按钮组件
        Button btn1 = (Button) findComponentById(ResourceTable.Id_btn1);
        //监听
        btn1.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                //创建 intent
                Intent i = new Intent();
                //设置参数
                i.setParam("username","张三");
                i.setParam("age",18);
                i.setStringArrayListParam("hobby", (ArrayList<String>) Arrays.asList("敲代码","读书","爬山"));
                    //设置跳转页面  要传递的参数
                present(new NextAbilityslice(),i);
            }
        });

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
